﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace RAMED
{
    public partial class CompletForm : Form
    {
        private Dossier_incomplet di = new Dossier_incomplet();

        public Dossier_incomplet Di
        {
            get { return di; }
            set { di = value; }
        }
        public RechercheDossierFormcs recherchedossier = new RechercheDossierFormcs();

       
        public CompletForm()
        {
            InitializeComponent();

            RAMEDEntities1 Context = SingletonContext.GetContext();
            comboBoxresp.DataSource = Context.Responsables;
            comboBoxresp.DisplayMember = "nom_prenom_responsable";

        }

        private void CompletForm_Load(object sender, EventArgs e)
        {

        }

        private void Button21_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }
        public void InitialiserChamps()
        {
            //txtnumdoss.Text = di.num_dossier.ToString();
            //txtchamps.Text = di.champs_manquent; 
            //txtnom.Text = di.Nom;
            //txtprenom.Text = di.Prenom;
            //txtCIN.Text = di.CIN;


            //comboBoxannexe.SelectedValue = di.Annexe_administratif.id_annexe_administratif;
        }
        
        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void btnvalider_Click(object sender, EventArgs e)
        {
            //RAMEDEntities1 Context = SingletonContext.GetContext();
            //Dossier_incomplet completajoute = new Dossier_incomplet();
            //int id_Dossier_incomplet = ((Dossier_incomplet)dataGridView.CurrentRow.DataBoundItem).id_dossier_incomplet;
            //completajoute = Context.Dossier_incomplet.Where(d => d.id_dossier_incomplet == id_Dossier_incomplet).First();
            //completajoute.id_responsable = ((Responsable)comboBoxresp.SelectedValue).id_responsable;
            //completajoute.Date_complet = dateTimePickercomp.Value;
            //completajoute.Documents = txtdocument.Text;
            //completajoute.complet=true;

            //Context.Dossier_incomplet.AddObject(completajoute);
            //Context.SaveChanges();
            //this.Dispose();

           // RAMEDEntities1 context = SingletonContext.GetContext();
           // Dossier_incomplet completajoute = new Dossier_incomplet();
           // //int id_Dossier_incomplet = ((Dossier_incomplet)dataGridView.CurrentRow.DataBoundItem).id_dossier_incomplet;
           // //completajoute = context.Dossier_incomplet.Where(d => d.id_dossier_incomplet == id_Dossier_incomplet).First();
           // completajoute.id_responsable = ((Responsable)comboBoxresp.SelectedValue).id_responsable;
           // completajoute.Date_complet = dateTimePickercomp.Value;
           // completajoute.Documents = txtdocument.Text;
           // completajoute.complet = true;

           //context.Dossier_incomplet.AddObject(completajoute);
           //context.SaveChanges();
           //this.Dispose();

           RAMEDEntities1 context = SingletonContext.GetContext();
           Dossier_incomplet completajoute = new Dossier_incomplet();
           completajoute = context.Dossier_incomplet.Where(c => c.id_dossier_incomplet == Di.id_dossier_incomplet).First();
           completajoute.id_responsable = ((Responsable)comboBoxresp.SelectedValue).id_responsable;
           completajoute.Documents = txtdocument.Text;
           completajoute.Date_complet = dateTimePickercomp.Value;
           completajoute.complet = true;
           context.SaveChanges();
           //SendMail.Send("ramedchefchouen@interieur.gov.ma", "ramedchefchouen@interieur.gov.ma", "DEVALIDATION DE DEMANDE", "");
           this.Dispose();
            
        }
         //public Dossier_incomplet dossi { get; set; }



    }
}
